package com.company.mvvm.base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import androidx.viewbinding.ViewBinding;

/**
 * 父类
 */
public abstract class BaseAct<T extends ViewBinding, VM extends ViewModel> extends AppCompatActivity {

    protected T binding;

    protected VM viewModel;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = getViewBinding();
        viewModel = new ViewModelProvider(this).get(getModel());

        setContentView(binding.getRoot());

        initView();

        initData();
    }

    protected abstract void initView();

    protected abstract void initData();


    protected abstract T getViewBinding();

    protected abstract Class<VM> getModel();
}
